public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            System.out.println("线程开始");
            try {
                Thread.sleep(1000);//休眠线程 xxx ms
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"1号线程");
        thread.setDaemon(true);//设置为后台线程
        thread.start();
        System.out.println(thread.getName() + " " + thread.isAlive());
        Thread.sleep(3000);
        System.out.println("线程结束");
        System.out.println(thread.isAlive());
    }
}
